$(function() {
	
	loadData();
	});

function loadData(){
	var currPage=$("#currPage").val();
	var search=$("#search").val();
	$.ajax({
		url : basePath + "linkAricle/toSearchLinkAricleList.spring",
		type : "POST",
		data:{search:search,
			currPage:currPage},
		dataType : 'json',
		success : function(ret) {
			console.log(ret);
			if (ret.list.length>0) {
				var html="";
				$("#zixun").html("");
				$("#curr").text(ret.currPage);
				$("#total").text(ret.totalPage);
				$("#currPage").val(ret.currPage);
				$("#totalPage").val(ret.totalPage);
				for (var i = 0; i < ret.list.length; i++) {
					var data=ret.list[i];
					html+=" <div class=\"weui_cell\" style=\"font-size:15px;\" onclick=\"document.location='"+data.linkAricle+"';\">";
					html+=" <div class=\"weui_cell_bd weui_cell_primary\">";
					if(data.title.length>10){
					html+="  <p>"+data.title.substring(0,10)+"...</p>";
					}else{
						html+="  <p>"+data.title+"...</p>";
					}
					html+="</div>";
					html+=" <div class=\"weui_cell_ft\">"+data.startTime.substring(0,19)+"</div>";
					html+="</div>";
					
				}
				$("#zixun").append(html);

			} else {
				var html="";
				$("#zixun").html("");
				html+=" <div class=\"weui_cell\" style=\"font-size:15px;\" >";
				html+=" <div class=\"weui_cell_bd weui_cell_primary\">";
				html+="  <p style=\"text-align:-webkit-center\"> 暂无数据</p>";
				html+="</div>";
				html+=" <div class=\"weui_cell_ft\"></div>";
				html+="</div>";
				$("#zixun").append(html);
			}
		}
	});
}
/**
 * 上一页
 */
function pre(){
	var totalPage=$("#totalPage").val();
	var currPage=$("#currPage").val();
	if(Number(currPage)==1){
		alert("已经是第一页");
	}else{
		var prePage=Number(currPage)-1;
		$("#currPage").val(prePage);
		loadData();
	}
}
/**
 * 下一页
 */
function next(){
	var totalPage=$("#totalPage").val();
	var currPage=$("#currPage").val();
	var nextPage=Number(currPage)+1;
	if(currPage>=totalPage){
		alert("已经是最后一页了");
	}else{
		$("#currPage").val(nextPage);
		loadData();
	}
}
/**
 * 搜索
 */
function toSearch(){
	
	loadData();
}